ggplot(merged, aes(mean_z_tmax, agb_gain - fitted_GAM8)) +geom_point() +geom_smooth(method ="lm", color ="red", se =FALSE) +facet_wrap(~ Treatment, scales ="free_y")+ggtitle("GAM8 residuals vs Tmax")
GAM5 bs = “fs”
Code
#test GAM that is done on the full models (bs = "fs")merged <- merged %>%mutate(fitted_GAM5_fs =predict(gam(agb_gain ~s(Year, subplot, bs ="fs", k =5), data =cur_data()),newdata =cur_data() ) )
Code
p111=ggplot(merged, aes(x = Year, y = fitted_GAM5_fs, color = subplot)) +geom_line(size =1) +# predicted trajectorygeom_point(data = merged, aes(x = Year, y = agb_gain, color = subplot),inherit.aes =FALSE, size =2) +# observed pointstheme_bw() +facet_wrap(~ subplot, scales ="free_y")+labs(x ="Year", y ="agb_gain", title="GAM-k=5 fs") +theme(legend.position ="none")p111
ggplot(merged, aes(mean_z_tmax, agb_gain - fitted_GAM5_fs)) +geom_point() +geom_smooth(method ="lm", color ="red", se =FALSE) +facet_wrap(~ Treatment, scales ="free_y")+ggtitle("GAM5 bs = “fs” residuals vs Tmax")
Code
#GAM captures early and late patterns faithfully, best edges behaviour. more variance on early years not linked to the model
slider
complete=TRUE (reject incomplete windows, NA at the beggining and the end), window per observation, not true “moving time windows”, window is just row-based.
ggplot(merged, aes(mean_z_tmax, agb_gain - fitted_slide_complete)) +geom_point() +geom_smooth(method ="lm", color ="red", se =FALSE) +facet_wrap(~ Treatment, scales ="free_y")+ggtitle("slide_complete residuals vs Tmax")
complete=TRUE (reject incomplete windows, increased window NA at the beggining and the end), window per observation, not true “moving time windows”, window is just row-based.